#ifndef BIGDECIMAL_BIGDECIMAL_H
#define BIGDECIMAL_BIGDECIMAL_H

#include "UBigNumber.h"

struct BigDecimal {
    struct UBigNumber integer;
    struct UBigNumber decimal;
    int sign; // 0 表示正数, 1 表示负数
};

struct BigDecimal InputBD(char * s);

struct BigDecimal AddBD(struct BigDecimal * pA, struct BigDecimal * pB);
struct BigDecimal SubBD(struct BigDecimal * pA, struct BigDecimal * pB);
struct BigDecimal MultiplyBD(struct BigDecimal * pA, struct BigDecimal * pB);
struct BigDecimal DivBD(struct BigDecimal * pA, struct BigDecimal * pB,int R);
void DestroyBD(struct BigDecimal * pBD);
void PrintBD(struct BigDecimal bd);

/* 辅助函数 */
struct UBigNumber _Concat(struct UBigNumber * pA, struct UBigNumber * pB); /* 连接整数部分和小数部分, 忽略小数点 */
struct BigDecimal _AddUBD(struct BigDecimal * pA, struct BigDecimal * pB);
struct UBigNumber _AddInteger(struct UBigNumber * pA, struct UBigNumber * pB, int iCarry);
struct UBigNumber _AddDecimal(struct UBigNumber * pA, struct UBigNumber * pB, int * piCarry);
struct BigDecimal _SubUBD(struct BigDecimal * pA, struct BigDecimal * pB);
struct UBigNumber _SubInteger(struct UBigNumber * pA, struct UBigNumber * pB, int iCarry);
struct UBigNumber _SubDecimal(struct UBigNumber * pA, struct UBigNumber * pB, int * piCarry);
struct BigDecimal _MultiplyUBD(struct BigDecimal * pA, struct BigDecimal * pB);
struct BigDecimal _DivUBD(struct BigDecimal * pA, struct BigDecimal * pB, int R);
void _NormalizeDecimal(struct UBigNumber * pUBN);
void _alignDecimal(struct UBigNumber * pA, struct UBigNumber * pB);
struct UBigNumber _InputDecimal(char * s);
void _AppendDecimalDigit(struct UBigNumber * pUBN, int digit); /* 小数在末尾添加一位无需考虑末尾为 0 的特殊情况 */
int _CompareUBN(struct UBigNumber * pA, struct UBigNumber * pB);
int _CompareUBD(struct BigDecimal * pA, struct BigDecimal * pB);
#endif //BIGDECIMAL_BIGDECIMAL_H
